/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t_ora_STRING_toChar.c                                */
/*  NOTE      =                                                    */
/*  DATE      = 2016/03/17 by geyh                                 */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "../../../../../src/module/oracle/config.h"
#include "../../../test_ora_comm.h"
#include <oracle/ora_core.h>
#include <oracle/comm/ora_comm.h>
#include <oracle/tns/ora_packet.h>

#include <oracle/ttc/sql/ora_STRING.h>
#include <frct_comm.h>


static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

extern int ora_STRING_toChar(char *p_payload
        , unsigned int ui_payload_len
        , char **pp_out
        , int *p_i_out_len);

static void __case1(void)
{
    char *p_payload = (char *)frmemdup("test", 4);
    unsigned int ui_payload_len = 4;
    int i_ret = 0;
    char *p_out = NULL;
    int i_out_len = 0;
    
    i_ret = ora_STRING_toChar(p_payload, ui_payload_len, &p_out, &i_out_len);
    
    CU_ASSERT_EQUAL(i_ret, FR_SUCC);
    
    if(p_payload)
        frfree(p_payload);
    
    if(p_out)
        frfree(p_out);
    
    return;
}


int add_suite_t_ora_STRING_toChar(void)
{
    CU_pSuite pSuite = NULL;
    
    if ((pSuite = CU_add_suite(MODULE_NAME" t_ora_STRING_toChar()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;
    
    if (CU_add_test(pSuite, "case1", __case1) == NULL)
        return FR_FAIL;
    
    return FR_SUCC;
}
//
// Created by Win on 2016/3/18.
//

